<?php
class UserWeiboCommentAction extends FrontendAction
{
	public function __construct()
	{
		parent::__construct();
		$this->layout = 'ajax';
	}
	
	public function execute()
	{
		$id 	= (int)$this->context->post('id');
		if (!$id)exit;
		
		$weiboCommentService = new BaseDb2Service('weibo_comment C');
		$con = array();
		$con['fields'] 	= array('C.*','U.username','U.logo');
		$con['where'] 	= array('weibo_id'=>'eq:'.$id);
		$con['join'] 	=  ' LEFT JOIN '.$weiboCommentService->table('user').' U ON C.user_id=U.id';
		$con['orderby'] = 'C.id DESC';
		$rows	= $weiboCommentService->rows($con);
		foreach($rows as $k=>$v){
			if (!$v['logo']){
				$rows[$k]['logo'] = $this->data['baseurl'].'images/noavatar_small.jpg';
			}
			$rows[$k]['created'] = Util::getBeforeTimelag(strtotime($v['created']));
		}
		$this->data['weibo']['id'] = $id;
		$this->data['comments'] = $rows;
		
	}
}
